package com.stropheware.droidDefense;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextPaint;

public class PlayerMenu {
	
	private GameManager manager;
	private int height;
	private int width;
	
	private Paint backgroundPaint;
	private Rect backgroundRect;
	private TextPaint textPaint = new TextPaint();
	
	private final static String COIN = "Coin: ";
	private final static String LIVES = "Lives: ";
	private final static String SCORE = "Score: ";
	private final static String ROUND = "Round: ";
	//text dimensions
	private final float textHeight;
	private final float coinWidth;
	private final float livesWidth;
	private final float scoreWidth;
	private final float roundWidth;
	private final float coinOffset;
	private final float livesOffset;
	private final float scoreOffset;
	private final float roundOffset;
	
	
	public PlayerMenu(GameBoard gameBoard, GameManager manager, Context context){
		
		this.manager = manager;
		height = gameBoard.actualBottomMenuHeight;
		width = gameBoard.actualWidth-gameBoard.actualMenuWidth;
		backgroundPaint = new Paint(Color.BLACK);
		backgroundRect = new Rect();
		backgroundRect.set(0, gameBoard.actualHeight - height, gameBoard.actualWidth-gameBoard.actualMenuWidth, gameBoard.actualHeight);
		textPaint = new TextPaint();
		textPaint.setAntiAlias(true);
		textPaint.setTextSize(15*gameBoard.densityScalar);
		textHeight = gameBoard.actualHeight - height/4;
		coinWidth =  46*gameBoard.densityScalar;
		livesWidth = width/4 + 41*gameBoard.densityScalar;
		scoreWidth = width/2 + 46*gameBoard.densityScalar;
		roundWidth = 3*width/4 + 51*gameBoard.densityScalar;
		coinOffset = 10;
		livesOffset = width/4;
		scoreOffset = width/2;
		roundOffset = 3*width/4;
		
	}

	public void drawMenu(Canvas canvas){
		canvas.drawRect(backgroundRect, backgroundPaint);
		
		//drawlabels
		textPaint.setColor(0xff74AC23);
		canvas.drawText(COIN, coinOffset , textHeight, textPaint);
		canvas.drawText(LIVES,  livesOffset,  textHeight, textPaint);
		canvas.drawText(SCORE, scoreOffset,  textHeight, textPaint);
		canvas.drawText(ROUND, roundOffset ,  textHeight, textPaint);
		
		//drawinfo
		textPaint.setColor(Color.GREEN);
		canvas.drawText(manager.getCoin(), coinWidth, textHeight, textPaint);
		canvas.drawText(manager.getLives(), livesWidth,textHeight, textPaint);
		canvas.drawText(manager.getScore(),  scoreWidth, textHeight, textPaint);
		canvas.drawText(manager.getRound(), roundWidth, textHeight, textPaint);

	}
	
}
